//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

public class EnemyTank extends Tank implements Runnable{
    public EnemyTank(int x, int y) {
        super(x, y);
        this.setType(0);
        this.setSpeed(10);
        this.setDirection(0);
        this.setLife(true);
    }

    @Override
    public void run() {
        while(true){
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            switch (this.getDirection()){
                case 0:
                    for(int l = 0; l < 5; l ++){
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        down();
                    }
                    break;
                case 1:
                    for(int l = 0; l < 5; l ++){
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        up();
                    }
                    break;
                case 2:
                    for(int l = 0; l < 5; l ++){
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        right();
                    }
                    break;
                case 3:
                    for(int l = 0; l < 5; l ++){
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        left();
                    }
                    break;
            }
            setDirection((int)(Math.random()*4));
            int rad = (int)(Math.random()*4);
            if(rad == 0){
                attack();
            }
        }
    }
}
